package com.example.business.controller.admin;

import com.example.common.response.PageResponse;
import com.example.common.response.R;
import com.example.business.request.ProductSkuListRequest;
import com.example.business.response.ProductSkuResponse;
import com.example.business.service.ProductSkuService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.business.request.ProductSkuRequest;
import java.util.List;

@RestController
@RequestMapping("admin/product-sku")
public class ProductSkuAdminController {
    @Autowired
    ProductSkuService productSkuService;

    @GetMapping("list")
    public R<PageResponse<ProductSkuResponse>> list(@Valid ProductSkuListRequest request) {
        PageResponse<ProductSkuResponse> list = productSkuService.list(request);
        return R.ok(list);
    }
    @PostMapping("save")
    public R<Object> save(@Valid @RequestBody ProductSkuRequest request) {
        productSkuService.save(request);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R<Integer> delete(@RequestBody List<Long> ids) {
        int result = productSkuService.deleteBatch(ids);
        return R.ok(result);
    }
}
